package com.yh.autobio.api;

import com.yh.autobio.modules.bean.CM;
import com.yh.autobio.modules.bean.Contact;
import com.yh.autobio.modules.bean.CustPhone;
import com.yh.autobio.modules.bean.InvoiceBean;
import com.yh.autobio.modules.bean.KCQty;
import com.yh.autobio.modules.bean.PackingBean;
import com.yh.autobio.modules.bean.PackingEntryBean;
import com.yh.autobio.modules.bean.ProductBean;
import com.yh.autobio.modules.bean.Result;
import com.yh.autobio.modules.bean.Update;
import com.yh.autobio.modules.bean.User;
import com.yh.autobio.modules.bean.WLBean;

import java.util.List;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PartMap;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by imyar on 2016/2/16 0016.
 */
public interface ApiInterface {


    //正式
    public final static String HOSTD = "192.168.1.9:8086";
    public final static String HOST = "192.168.1.9:8086/";

//    public final static String HOSTD = "192.168.1.127:62968";
//    public final static String HOST = "192.168.1.127:62968/";



//    public final static String HOSTD = "172.16.8.121:62968";
//    public final static String HOST = "172.16.8.121:62968/";


//    public final static String HOSTD = "192.168.1.102:18666";
//    public final static String HOST = "192.168.1.102:18666/";

    public static final String API_BASE = "api/";// A10PI版本
    public final static String HTTPS = "https://";
    public final static String HTTP = "http://";
    public final static String BASE_URL = HTTP + HOST;
    public final static String VERSION = HTTP + HOST + "apk/version.htm";

    //登录
    @POST("/api/Account/login_validate")
    Observable<Result> login(@Body Contact mContact);

    //获取用户信息
    @POST("/api/Account/userInfo")
    Observable<User> userInfo(@Body Contact mContact);

    //修改密码
    @POST(API_BASE + "/Account/EditPassWord")
    Observable<Result> EditPassWord(@Query("name") String name, @Query("orgPwd") String orgPwd, @Query("newPwd") String newPwd);

    //更新用户信息
    @Multipart
    @POST("/api/Account/updateUserInfo")
    Observable<Result> updateUserInfo(@PartMap Map<String, RequestBody> params, @Query("token") String token);

    @GET(API_BASE + "User/allWorkers")
    Observable<Result> allWorkers(@Query("token") String token);

    @GET(API_BASE + "GXHB/WorksById")
    Observable<Result> worksEntry(@Query("token") String token, @Query("workNo") String workNo, @Query("type") String type, @Query("gxid") int gxid, @Query("chejianId") int chejianId);

    @GET(API_BASE + "GXHB/WorksUndoById")
    Observable<Result> worksEntryUndo(@Query("token") String token, @Query("workNos") String workNos, @Query("key") String key, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    @GET(API_BASE + "GXHB/WorkInfos")
    Observable<Result> WorkInfos(@Query("token") String token, @Query("key") String key, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    @POST(API_BASE + "GXHB/WorkUpdate")
    Observable<Result> WorkUpdate(@Body CM cm);

    @GET(API_BASE + "GXHB/workersByGXId")
    Observable<Result> workersByGXId(@Query("GXId") int GXId, @Query("FDepartmentID") int FDepartmentID);

    //xinzeng
    @GET(API_BASE + "GXHB/WorksUnReported")
    Observable<Result> WorksUnReported(@Query("token") String token, @Query("gxid") int gxid, @Query("chejianId") int chejianId, @Query("start") String start, @Query("end") String end);

    @POST(API_BASE + "GXHB/WorkReportUpdate")
    Observable<Result> WorkReportUpdate(@Body CM cm);

    @GET(API_BASE + "Work/RKS_PDA")
    Observable<Result> RKS(@Query("token") String token, @Query("workNos") String workNos);

    @GET(API_BASE + "Work/RKS_One")
    Observable<Result> RKS_One(@Query("token") String token, @Query("workNo") String workNo);

    @GET(API_BASE + "Work/LocalS_GetAll")
    Observable<Result> LocalS_GetAll();

    @GET(API_BASE + "Work/Departmen_GetAll")
    Observable<Result> Departmen_GetAll();

    @POST(API_BASE + "Work/RKS_CheckIn")
    Observable<Result> RKS_CheckIn(@Body CM cm);

    @GET(API_BASE + "Work/SaleBillEntyAllMy")
    Observable<Result> SaleBillEntyAllMy(@Query("token") String token, @Query("fentryId") int fentryId, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    @GET(API_BASE + "Work/SaleBillAllMy")
    Observable<Result> SaleBillAllMy(@Query("token") String token, @Query("type") String type, @Query("key") String key, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    @GET(API_BASE + "Work/CKS_Undo_Page")
    Observable<Result> CKS_Undo_Page(@Query("token") String token, @Query("key") String key, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    @GET(API_BASE + "Work/CKS")
    Observable<Result> CKS(@Query("token") String token);

    @GET(API_BASE + "Work/WorkInfo_IsRK")
    Observable<Result> WorkInfo_IsRK(@Query("billers") String billers, @Query("itemsn") String itemsn);

    @GET(API_BASE + "Work/WorkInfo_Doors_CK")
    Observable<Result> WorkInfo_Doors_CK(@Query("billers") String billers);

    @GET(API_BASE + "Work/WorkInfo_Doors_RK")
    Observable<Result> WorkInfo_Doors_RK(@Query("billers") String billers);

    @POST(API_BASE + "Work/CKS_CheckOut")
    Observable<Result> CKS_CheckOut(@Body CM cm);

    //当月薪水
    @GET(API_BASE + "GXHB/salery_Month")
    Observable<Result> salery_Month(@Query("userId") int userId, @Query("fgongxu") int fgongxu, @Query("userType") String userType, @Query("year") int year, @Query("month") int month, @Query("pageSize") int pageSize, @Query("pageIndex") int pageIndex);

    //获得12个月的薪水情况
    @GET(API_BASE + "GXHB/salery_Month12")
    Observable<Result> salery_Month12(@Query("userId") int userId, @Query("fgongxu") int fgongxu, @Query("userType") String userType, @Query("year") int year);

    @GET(VERSION)
    Observable<Update> upDateApp();

    //客服电话
    @GET(API_BASE + "Common/ServicePhoneAll")
    Observable<List<CustPhone>> ServicePhoneAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    /**
     * 发货仓库
     *
     * @return
     */
//    @GET(API_BASE + "Common/StockAll")
//    Observable<List<CustPhone>> StockAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    /**
     * 购货单位
     *
     * @return
     */
    @GET(API_BASE + "Common/OrganizationAll")
    Observable<List<CustPhone>> OrganizationAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);


    /**
     * 销售方式
     *
     * @return
     */
    @GET(API_BASE + "Common/SaleMethodAll")
    Observable<List<CustPhone>> SaleMethodAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    //货运部
    @GET(API_BASE + "Common/TransportDepartmentAll")
    Observable<List<CustPhone>> TransportDepartmentAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    //收款方式
    @GET(API_BASE + "Common/ReceivableMethodAll")
    Observable<List<CustPhone>> ReceivableMethodAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    //业务员
    @GET(API_BASE + "Common/SalesmanAll")
    Observable<List<CustPhone>> SalesmanAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    //即时库存
    @GET(API_BASE + "Common/GetFirstStock")
    Observable<KCQty> GetFirstStock(@Query("StockId") String  StockId, @Query("ItemId") String ItemId);


    @GET(API_BASE + "Common/SyncInfosAll")
    Observable<WLBean> SyncInfosAll();

    @POST(API_BASE + "Work/StockBillSubmit")
    Observable<Result> StockBillSubmit(@Body CM cm);


    //安图
    @GET(API_BASE + "Common/StockAll")
    Observable<List<InvoiceBean>> StockAll(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    @GET(API_BASE + "Common/FCodeAll")
    Observable<List<ProductBean>> FCodeAll(@Query("name") String name);

    @POST(API_BASE + "Work/PickSubmitZxd")
    Observable<Result> PickSubmitZxd(@Body CM cm);

    @GET(API_BASE + "Common/StockPacking")
    Observable<List<PackingBean>> StockPacking(@Query("name") String name, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);

    @GET(API_BASE + "Common/FPackingAll")
    Observable<List<PackingEntryBean>> FPackingAll(@Query("id") String id);

}
